<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;

/**
 * Class OrderExpress
 * 
 * @property int $id
 * @property int $order_id
 * @property int|null $express_id
 * @property string|null $express_name
 * @property string|null $express_sn
 * @property int $status
 * @property string|null $express_details
 * @property Carbon|null $create_at
 * @property Carbon|null $update_at
 * @property Carbon|null $delete_at
 *
 * @package App\Models
 */
class OrderExpress extends BaseModels
{
	protected $table = 'zh_order_express';
	public $timestamps = false;

	const WAITING = 0; //暂无轨迹

    const COLLECT = 1; //已揽收

	const ON_LINE = 2; //在途中

    const SIGNED = 3; //已签收

    const ERROR = 4; //问题件


	protected $casts = [
		'order_id' => 'int',
		'express_id' => 'int',
        'status' => 'int'
	];

	protected $appends = [
	    'status_msg'
    ];


	public function getStatusMsgAttribute()
    {
        switch ($this->status){
            case self::WAITING:
                return '暂无轨迹';
            case self::COLLECT:
                return '已揽收';
            case self::ON_LINE:
                return '在途中';
            case self::SIGNED:
                return '已签收';
            case self::ERROR:
                return '问题件';
            default:
                return '未知';

        }
    }
	protected $dates = [
		'create_at',
		'update_at',
		'delete_at'
	];

	protected $fillable = [
		'order_id',
		'express_id',
		'express_name',
		'express_sn',
		'status',
        'express_details',
		'create_at',
		'update_at',
		'delete_at'
	];
}
